<!-- FORMS -->
<div class="row">
    <div class="col-md-12">
        <!-- BASIC -->

        <div class="box border orange">
            <div class="box-title">
                <h4><i class="fa fa-user"></i>Edit Operator</h4>
            </div>
            <div class="box-body big">
                <div class="row">
                    <div class="col-md-12">
                        <div class="tabbable tabbable-custom">
                            <ul class="nav nav-tabs">
                                <li class="active"><a href="#tab_1_1" data-toggle="tab"><i class="fa fa-user"></i> Operator</a></li>
                                <li><a href="#tab_1_2" data-toggle="tab"><i class="fa fa-angle-double-up"></i> Atasan Langsung</a></li>
                                <li><a href="#tab_1_3" data-toggle="tab"><i class="fa fa-angle-double-down"></i> Bawahan Langsung</a></li>
                            </ul>
                            <div class="tab-content">
                                <div class="tab-pane active" id="tab_1_1">
                                    <div class="box-body big">
                                        <?php echo form_open('operator/update_operator', 'class="form-horizontal row-border"'); ?>
                                        <?php // extract($operator);?>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">Nama:</label> 
                                            <div class="col-md-10"><input class="form-control" type="text" name="nama" value="<?php echo $operator->nama; ?>" /></div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">NIK:</label> 
                                            <div class="col-md-10"><input class="form-control" type="text" name="nik" value="<?php echo $operator->nik; ?>" /></div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">Jabatan:</label> 
                                            <div class="col-md-10"><input class="form-control" type="text" name="jabatan" value="<?php echo $operator->jabatan; ?>" /></div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">Email:</label> 
                                            <div class="col-md-10"><input class="form-control" type="text" name="email" value="<?php echo $operator->email; ?>" /></div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-md-2 control-label">Username:</label> 
                                            <div class="col-md-10"><input class="form-control" type="text" name="username" value="<?php echo $operator->username; ?>" /></div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">Password:</label> 
                                            <div class="col-md-10"><input class="form-control" type="text" name="password" value="<?php echo $operator->password; ?>" /></div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">Nomor Handphone:</label> 
                                            <div class="col-md-10"><input class="form-control" type="text" name="no_hp" value="<?php echo $operator->no_hp; ?>" /></div>
                                        </div>
                                        <div class="form-group">
                                            <label class="control-label col-md-2">Status</label>
                                            <div class="col-md-10">
                                                <select name="status" id="country_select" class="col-md-12 full-width-fix" value="<?php echo $operator->status; ?>">
                                                    <option value="" />
                                                    <?php if ($operator->status == 1) { ?>
                                                        <option value="1" selected="selected"/>Aktif
                                                        <option value="0"/>Tidak Aktif
                                                    <?php } else { ?>
                                                        <option value="1"/>Aktif
                                                        <option value="0" selected="selected"/>Tidak Aktif 
                                                    <?php }
                                                    ?>
                                                </select>
                                            </div>
                                        </div>
                                        <input type="hidden" name="id_operator" value="<?php echo $operator->id_operator; ?>" />
                                        <div class="pull-right"><button class="btn btn-warning" type="submit" name="submit" value="update_operator">Update Data</button></div>
                                        <br/>
                                        </form>				
                                    </div>
                                </div>
                                <div class="tab-pane" id="tab_1_2">
                                    <div class="box-body big">
                                        <?php echo form_open('operator/edit_atasan', array('class' => 'form-horizontal row-border', 'id' => 'atasan', 'onsubmit' => 'return false')); ?>
                                        <input type="hidden" name="id_operator" value="<?php echo $this->uri->segment(3); ?>"/>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label" for="input2">Atasan Langsung</label> 
                                            <div class="col-md-8">
                                                <select id="input1" class="select2-01 col-md-12 full-width-fix" multiple="multiple" size="5" name="atasan_lsg[]">
                                                    <?php foreach ($list as $l) { ?>
                                                        <?php if (!in_array($l->id_operator, $atasan)) { ?>
                                                            <option value="<?php echo $l->id_operator; ?>"><?php if($l->nama != $operator->nama) echo $l->nama; ?></option>
                                                            <?php
                                                        }
                                                    }
                                                    ?>
                                                </select>
                                            </div>
                                            <button type="submit" class="btn btn-warning" id="tambah_atasan">Tambah</button>
                                        </div>
                                        </form>
                                    </div>
                                    <div class="box-body big">
                                        <table class="table table-hover" id="tabel_atasan">
                                            <thead>
                                                <tr>
                                                    <th>Nama</th>
                                                    <th>Option</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php foreach ($nama_ats->result() as $l) { ?>
                                                    <tr>
                                                        <td><?php echo $l->nama; ?></td>
                                                        <td><a id="id_formasi" href="<?php echo site_url('operator/hapus_formasi') . '/' . $l->id_formasi; ?>" onclick="return confirm('Apakah Anda yakin ingin menghapus data ini?');"><i class="fa fa-times fa-fw tip-bottom" title="hapus"></i></a></td>
                                                    </tr>
                                                <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <div class="tab-pane" id="tab_1_3">
                                    <div class="box-body big">
                                        <?php echo form_open('operator/edit_bawahan', array('class' => 'form-horizontal row-border', 'id' => 'bawahan', 'onsubmit' => 'return false')); ?>
                                        <input type="hidden" name="id_operator" value="<?php echo $this->uri->segment(3); ?>"/>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label" for="input2">Bawahan Langsung</label> 
                                            <div class="col-md-8">
                                                <select id="input1" class="select2-01 col-md-12 full-width-fix" multiple="multiple" size="5" name="bawahan_lsg[]">
                                                    <?php foreach ($list as $l) { ?>
                                                        <?php if (!in_array($l->id_operator, $bawahan)) { ?>
                                                            <option value="<?php echo $l->id_operator; ?>"><?php if($l->nama != $operator->nama) echo $l->nama; ?></option>
                                                            <?php
                                                        }
                                                    }
                                                    ?>
                                                </select>
                                            </div>
                                            <button type="submit" class="btn btn-warning" id="tambah_bawahan">Tambah</button>
                                        </div>
                                        </form>
                                    </div>
                                    <div class="box-body big">
                                        <table class="table table-hover" id="tabel_bawahan">
                                            <thead>
                                                <tr>
                                                    <th>Nama</th>
                                                    <th>Option</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php foreach ($nama_bwh->result() as $l) { ?>
                                                    <tr>
                                                        <td><?php echo $l->nama; ?></td>
                                                        <td><a id="id_formasi" href="<?php echo site_url('operator/hapus_formasi') . '/' . $l->id_formasi; ?>" onclick="return confirm('Apakah Anda yakin ingin menghapus data ini?');"><i class="fa fa-times fa-fw tip-bottom" title="hapus"></i></a></td>
                                                    </tr>
                                                <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- /BASIC -->
</div>
</div>
<!-- /SAMPLE -->

<!-- JAVASCRIPTS -->
<!-- Placed at the end of the document so the pages load faster -->
<!-- JQUERY -->
<script src="<?php echo base_url() . 'assets/js/jquery/jquery-2.0.3.min.js'; ?>"></script>
<!-- JQUERY UI-->
<script src="<?php echo base_url() . 'assets/js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js'; ?>"></script>
<!-- BOOTSTRAP -->
<script src="<?php echo base_url() . 'assets/bootstrap-dist/js/bootstrap.min.js'; ?>"></script>


<!-- DATE RANGE PICKER -->
<script src="<?php echo base_url() . 'assets/js/bootstrap-daterangepicker/moment.min.js'; ?>"></script>

<script src="<?php echo base_url() . 'assets/js/bootstrap-daterangepicker/daterangepicker.min.js'; ?>"></script>
<!-- SLIMSCROLL -->
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/jQuery-slimScroll-1.3.0/jquery.slimscroll.min.js'; ?>"></script>
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/jQuery-slimScroll-1.3.0/slimScrollHorizontal.min.js'; ?>"></script>
<!-- BLOCK UI -->
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/jQuery-BlockUI/jquery.blockUI.min.js'; ?>"></script>
<!-- TYPEHEAD -->
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/typeahead/typeahead.min.js'; ?>"></script>
<!-- AUTOSIZE -->
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/autosize/jquery.autosize.min.js'; ?>"></script>
<!-- COUNTABLE -->
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/countable/jquery.simplyCountable.min.js'; ?>"></script>
<!-- INPUT MASK -->
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/bootstrap-inputmask/bootstrap-inputmask.min.js'; ?>"></script>
<!-- FILE UPLOAD -->
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/bootstrap-fileupload/bootstrap-fileupload.min.js'; ?>"></script>
<!-- SELECT2 -->
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/select2/select2.min.js'; ?>"></script>
<!-- UNIFORM -->
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/uniform/jquery.uniform.min.js'; ?>"></script>
<!-- JQUERY UPLOAD -->
<!-- The Templates plugin is included to render the upload/download listings -->
<script src="<?php echo base_url() . 'assets/js/blueimp/javascript-template/tmpl.min.js'; ?>"></script>
<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
<script src="<?php echo base_url() . 'assets/js/blueimp/javascript-loadimg/load-image.min.js'; ?>"></script>
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
<script src="<?php echo base_url() . 'assets/js/blueimp/javascript-canvas-to-blob/canvas-to-blob.min.js'; ?>"></script>
<!-- blueimp Gallery script -->
<script src="<?php echo base_url() . 'assets/js/blueimp/gallery/jquery.blueimp-gallery.min.js'; ?>"></script>
<!-- The basic File Upload plugin -->
<script src="<?php echo base_url() . 'assets/js/jquery-upload/js/jquery.fileupload.min.js'; ?>"></script>
<!-- The File Upload processing plugin -->
<script src="<?php echo base_url() . 'assets/js/jquery-upload/js/jquery.fileupload-process.min.js'; ?>"></script>
<!-- The File Upload image preview & resize plugin -->
<script src="<?php echo base_url() . 'assets/js/jquery-upload/js/jquery.fileupload-image.min.js'; ?>"></script>
<!-- The File Upload audio preview plugin -->
<script src="<?php echo base_url() . 'assets/js/jquery-upload/js/jquery.fileupload-audio.min.js'; ?>"></script>
<!-- The File Upload video preview plugin -->
<script src="<?php echo base_url() . 'assets/js/jquery-upload/js/jquery.fileupload-video.min.js'; ?>"></script>
<!-- The File Upload validation plugin -->
<script src="<?php echo base_url() . 'assets/js/jquery-upload/js/jquery.fileupload-validate.min.js'; ?>"></script>
<!-- The File Upload user interface plugin -->
<script src="<?php echo base_url() . 'assets/js/jquery-upload/js/jquery.fileupload-ui.min.js'; ?>"></script>
<!-- The main application script -->
<script src="<?php echo base_url() . 'assets/js/jquery-upload/js/main.js'; ?>"></script>
<!-- COOKIE -->
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/jQuery-Cookie/jquery.cookie.min.js'; ?>"></script>
<!-- CUSTOM SCRIPT -->
<script src="<?php echo base_url() . 'assets/js/script.js'; ?>"></script>
<script>
                                                        jQuery(document).ready(function() {
                                                            App.setPage("forms");  //Set current page
                                                            App.init(); //Initialise plugins and elements
                                                        });
</script>
<!-- /JAVASCRIPTS -->
<script>
    $(document).ready(function() {
        $('#atasan').submit(function() {
            $.ajax({
                type: 'post',
                url: $(this).attr('action'),
                data: $(this).serialize(),
                dataType: 'json',
                success: function(data) {
                    //$('#tabel_atasan').append('<tr><td></td><td>tr</td></tr>');
                    if (data.status) {
                        $.each(data.get_atasan, function(a, atasan) {
                            $('#tabel_atasan').append('<tr><td>' + atasan.nama + '</td><td>' + atasan.id_formasi + '</td></tr>');
                        })
                    }
                },
                error: function() {
                    alert('ra dadi masdab!');
                }
            })
        })

        $('#bawahan').submit(function() {
            $.ajax({
                type: 'post',
                url: $(this).attr('action'),
                data: $(this).serialize(),
                dataType: 'json',
                success: function(data) {
                    //$('#tabel_atasan').append('<tr><td></td><td>tr</td></tr>');
                    if (data.status) {
                        $.each(data.get_bawahan, function(b, bawahan) {
                            $('#tabel_bawahan').append('<tr><td>' + bawahan.nama + '</td><td>' + bawahan.id_formasi + '</td></tr>');
                        })
                    }
                },
                error: function() {
                    alert('ra dadi masdab!');
                }
            })
        })
    });
</script>